﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace server.DataBase
{
    [Serializable]
    public class ForumPage
    {
        public string id { get; set; }
        public SortedDictionary<int, ForumPage> subs { get; set; }

        public ForumPage(string id)
        {
            this.id = id;
            this.subs = new SortedDictionary<int, ForumPage>();
        }

        public ForumPage(ForumPage forumPage)
        {
            this.id = (string)forumPage.id.Clone();
            this.subs = new SortedDictionary<int, ForumPage>();
            foreach (KeyValuePair<int, ForumPage> kvp in forumPage.subs)
            {
                this.subs.Add(kvp.Key, new ForumPage(kvp.Value.id));
            }
        }

        public override string ToString()
        {
            string result = "Page: " + this.id + "\n";
            foreach (KeyValuePair<int, ForumPage> kvp in subs)
            {
                result += kvp.Key + ") " + kvp.Value.id + "\n";
            }
            return result;
        }

        public ForumPage getSubPage(int index)
        {
            return this.subs.ElementAt(index).Value;
        }

    }
}
